package com.pb.infra.taskManage.controller;

import com.pb.infra.oth.entity.common.Result;
import com.pb.infra.taskManage.entity.MaJobRelyCfg;
import com.pb.infra.taskManage.service.MaJobRelyCfgService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * (MaJobRelyCfg)表控制层
 *
 * @author JYF
 * @since 2022-12-05 09:04:17
 */
@RestController
@RequestMapping("v1/maJobRelyCfg")
public class MaJobRelyCfgController {
    /**
     * 服务对象
     */
    @Resource
    private MaJobRelyCfgService maJobRelyCfgService;

    /**
     * 任务依赖关系--导入
     *
     * @param paramMap 查询实体
     * @return 所有数据
     */
    @PostMapping("/import")
    public Result jobRelyImport(@RequestParam Map<String, String> paramMap, MultipartHttpServletRequest multipartHttpServletRequest) {
        if (paramMap.get("groupName") == null || paramMap.get("groupName").trim().equals("")) {
            return Result.error("600", "缺少批次号");
        }
        if (paramMap.get("addType") == null || paramMap.get("addType").trim().equals("")) {
            return Result.error("600", "缺少添加模式");
        }
        MaJobRelyCfg maJobRelyCfg = new MaJobRelyCfg();
        maJobRelyCfg.setAddType(paramMap.get("addType"));
        maJobRelyCfg.setSysNo(paramMap.get("groupName"));
        return this.maJobRelyCfgService.jobRelyImport(maJobRelyCfg, multipartHttpServletRequest);
    }

    /**
     * 任务依赖关系--导出
     *
     * @param maJobRelyCfg 主键
     * @param response
     * @return 单条数据
     */
    @PostMapping("/export")
    public void jobRelyExport(@RequestBody MaJobRelyCfg maJobRelyCfg, HttpServletResponse response) {
        this.maJobRelyCfgService.jobRelyExport(maJobRelyCfg, response);

    }


}

